package com.sgcc.ln.pmos.mobileapp.presenter;


import com.sgcc.ln.pmos.common.base.BasePresenter;
import com.sgcc.ln.pmos.common.http.HttpInterConst;
import com.sgcc.ln.pmos.common.http.HttpRequestUtils;
import com.sgcc.ln.pmos.common.http.MvpNetCallback;
import com.sgcc.ln.pmos.mobileapp.bean.ConfigBean;
import com.sgcc.ln.pmos.mobileapp.contract.SplashContract;

import java.util.HashMap;
import java.util.Map;

import okhttp3.Call;

/**
 * @description 关于接口
 */
public class SplashPresenter extends BasePresenter<SplashContract.View>
        implements SplashContract.Presenter {

    @Override
    public void getVisibilConfig() {
        Map<String, Object> params = new HashMap<>();
        HttpRequestUtils.getInstance().request(params, HttpInterConst.HOME_CONFIGE, new MvpNetCallback<ConfigBean>(getView(), true) {
            @Override
            public void onError(Call call, Exception e, int id) {
                super.onError(call, e, id);
                if (!isViewAttached()) {
                    return;
                }
                // 失败回调 判断界面是否销毁
                getView().queryVisibilConfigFailed();
            }

            @Override
            public void onResponse(ConfigBean response, int id) {
                super.onResponse(response, id);
                if (!isViewAttached()) {
                    return;
                }
                getView().queryVisibilConfigSuccess(response);
            }
        });

    }
}
